;(function ($, window, document, undefined) {
	var BackTop = function ($el, options) {
		//保存jq节点
		this.element = $el;
		//保存配置样式
		this.default = {
                    "position": "fixed",
                    "bottom": "10px",
                    "right": "50px",
                    "z-index": "1030",
                    "cursor": "pointer",
                    "display": "none"
    	        };
    	this.opt = $.extend(true, {}, this.default, options);
	}

	//初始化
	BackTop.prototype.init = function(){
		var _self = this;
		this.element.css(this.opt)
            		.attr('title', '回到顶部')
            		.html('<i class="fa fa-angle-double-up fa-3x"></i>')
            		.on('click', function(event) {
            			$('html,body').animate({
							scrollTop: 0
						}, 'slow');
            		});

        //监听页面滚动
		$(window).scroll(function() {
			//滚动到页面离顶部距离大于100px时【回到顶部】按钮出现
			$(document).scrollTop() > 100? 
			_self.element.css('display', ''): 
			_self.element.css('display', 'none');
		});
		return this.element;
	};
	$.fn.pagescroll = function(options) {
		var bt = new BackTop(this, options);
		return bt.init();
	}
})(jQuery, window, document);